<%= turbo_frame_tag :resource_form, target: "_top" do %>
  <%= render component("ui/modal").new(title: t(".title")) do |modal| %>
    <%= solidus_form_for @role, url: form_url, html: { id: form_id } do |f| %>
      <div class="flex flex-col gap-6 pb-4">
        <%= f.text_field(:name, class: "required", placeholder: t(".name_placeholder")) %>
        <%= f.text_field(:description, placeholder: t(".description_placeholder")) %>
      </div>

      <% if permission_set_options.present? %>
        <h3 class="text-l py-4 font-semibold text-gray-900">
          <%= t(".choose_permissions") %>
        </h3>
      <% end %>

      <%= f.checkbox_row(:permission_set_ids, options: permission_set_options[:order], row_title: t('.orders')) %>
      <%= f.checkbox_row(:permission_set_ids, options: permission_set_options[:product], row_title: t('.products')) %>
      <%= f.checkbox_row(:permission_set_ids, options: permission_set_options[:stock], row_title: t('.stock')) %>
      <%= f.checkbox_row(:permission_set_ids, options: permission_set_options[:user], row_title: t('.customers')) %>
      <%= f.checkbox_row(:permission_set_ids, options: permission_set_options[:restricted_stock], row_title: t('.restricted_stock')) %>
      <%= f.checkbox_row(:permission_set_ids, options: permission_set_options[:configuration], row_title: t('.settings')) %>
      <%= f.checkbox_row(:permission_set_ids, options: permission_set_options[:other], row_title: t('.other'), layout: :subsection) %>

      <% modal.with_actions do %>
        <form method="dialog">
          <%= render component("ui/button").new(scheme: :secondary, text: t('.cancel')) %>
        </form>
        <%= f.submit %>
      <% end %>
    <% end %>
  <% end %>
<% end %>
